#include<bits/stdc++.h>
#define M 200010
#define rep(x,y,z) for (int x=y;x<=z;x++)
#define rep1(x,y,z) for (int x=y;x>=z;x--)
using namespace std;
typedef long long ll;
int T,n,a[M],b[M];
ll ans0=-1;
void work(int cnt){

    if (cnt==n+1){
        ll ans=0;
        rep1(i,n,1){
            rep1(j,i-1,1){
                if (b[i]==b[j] ){
                    if (a[i]==a[j])
                        ans+=a[j];
                    break;
                }

            }
        }
        ans0=max(ans,ans0);
        return;
    }
    b[cnt]=0;
    work(cnt+1);
    b[cnt]=1;
    work(cnt+1);
    return;

}

int main(){

    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        ans0=-1;
        memset(b,0,sizeof(b));
        cin>>n;
        rep(i,1,n)
            cin>>a[i];
        work(1);
        cout<<ans0<<'\n';

    }



}
